package com.smh.aiagent.rag;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author shiminghui
 * @date 2025/6/1 16:27
 * @description: TODO
 */
@Configuration
@Slf4j
@RequiredArgsConstructor
public class LoveAppVectorStoreConfig {
    private final LoveMarkdownDocumentLoader loveMarkdownDocumentLoader;
    private final EmbeddingModel dashscopeEmbeddingModel;

    @Bean
    public VectorStore loveAppVectorStore() {
        List<Document> documents = loveMarkdownDocumentLoader.loadMarkdownDocuments();
        SimpleVectorStore simpleVectorStore = SimpleVectorStore.builder(dashscopeEmbeddingModel)
                .build();
        simpleVectorStore.add(documents);
        return simpleVectorStore;
    }

}
